package java0819;

public class ThreadDemo14 {
    public static void main(String[] args) throws InterruptedException {
        Thread t = new Thread(){
            @Override
            public void run() {
                while (Thread.currentThread().isInterrupted()){
                    try {
                        Thread.sleep(100);
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                        break;
                    }

                }
            }
        };
        System.out.println(t.getId() + ":" + t.getState());
        t.start();
        System.out.println(t.getId() + ":" + t.getState());
        Thread.sleep(3000);
        t.interrupt();
        System.out.println(t.getId() + ":" + t.getState());
    }
}
